#include <iostream>

using namespace std;

#define N 5
#define M 5

int sum(int a[M][N]);

int main ( )
{
    int a[M][N],i,j,s;

    cout<<"enter the mat"<<endl;

    for(i=0;i<M;i++)
        for(j=0;j<N;j++)
        {
            cin>>a[i][j];
        }

        s=sum(a);

        cout<<"the sum of mat"<<s<<endl;

        cin>>s;
        return 0;
}

int sum(int a[M][N])
{
    int s=0,i,j;

    for(i=0;i<M;i++)
        for(j=0;j<N;j++)
        {
            if(i==0||i==M-1||j==0||j==N-1)
             s=s+a[i][j];
        }

        return s;
}
